#include <sys/stat.h>
#include <stdio.h>
#include <errno.h>

int main(int argc,char *argv[]){
	int i;
	struct stat buf;
	char *ptr;
	for (int i = 0; i < argc; ++i)
	{
		printf("文件名：%s，文件类型:",argv[i] );

		if (lstat(argv[i],&buf) < 0)
		{
			perror("lstat error");
			continue;
		}

		if (S_ISREG(buf.st_mode))
		{
			ptr = "regular";
		}else if (S_ISDIR(buf.st_mode))
		{
			/* code */
			ptr = "directory";
		}else if (S_ISBLK(buf.st_mode))
		{
			/* code */
			ptr = "block special";
		}else if (S_ISFIFO(buf.st_mode))
		{
			/* code */
			ptr = "fifo";
		}else if (S_ISLNK(buf.st_mode))
		{
			/* code */
			ptr = "symbloic link";
		}else if (S_ISSOCK(buf.st_mode))
		{
			/* code */
			ptr = "socket";
		}else{
			ptr = "*** nukonwn mode ***";
		}

		printf("%s\n",ptr );

	}

	return 0;
}